class LinkNode:
    def __init__(self,data = None):
        self.data = data
        self.next = None

class DLinkNode:
    def __init__(self, data = None):
        self.data = data
        self.next =  None
        self.prior = None

class CLinkList:
    def __init__(self):
        self.head = LinkNode()
        self.head.next = self.head

    def CreateListR(self, a):
        t = self.head
        for i in range(0, len(a)):
            s = LinkNode(a[i])
            t.next = s
            t = s
        t.next = self.head
        
    def display(self):
        p = self.head.next
        while p != self.head:
            print(p.data, end=' ')
            p = p.next
        print()

class DCLinkList:
    def __init__(self):
        self.dhead = DLinkNode()
        self.dhead.next = self.dhead
        self.dhead.prior = self.dhead
    
    def CreateListR(self, a):
        t = self.dhead
        for i in range(len(a)):
            s = DLinkNode(a[i])
            t.next = s
            s.prior = t
            t = s
        t.next = self.dhead
        self.dhead.prior = t

    def display(self):
        p = self.dhead.next
        while p != self.dhead:
            print(p.data, end=" ")
            p = p.next
        print()
    
    def getSize(self):
        p = self.dhead.next
        cnt = 0
        while p != self.dhead:
            cnt += 1
            p = p.next
        return cnt
